package com.jiangyifen.robot.websocket.internal;

/**
 * websocket 消息bean
 * 
 * @author 江毅奋
 * @email jiangyifen@icloud.com
 *
 */
public class WebsocketMessage {

	/**
	 * 消息过期时间
	 */
	private static int expireIn = 5000;// 5秒过期

	/**
	 * 消息创建时间
	 */
	private long createTime = 0l;
	private String message = null;
	private String clientId = null;

	/**
	 * 
	 * @param message
	 *            消息内容
	 * @param sendTo
	 *            发给谁，填写用户登陆名
	 */
	public WebsocketMessage(String message, String clientId) {
		createTime = System.currentTimeMillis();
		this.message = message;
		this.clientId=clientId;
	}

	/**
	 * 消息是否过期
	 * @return 消息过期返回true
	 */
	public boolean isExpired() {
		return ((System.currentTimeMillis() - createTime) > expireIn);
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getClientId() {
		return clientId;
	}

	public void setClientId(String clientId) {
		this.clientId = clientId;
	}

}
